package au.edu.unsw.infs3634.gamifiedlearning.actiivty;

import android.os.Bundle;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import au.edu.unsw.infs3634.gamifiedlearning.R;
import au.edu.unsw.infs3634.gamifiedlearning.adapter.VideoListAdapter;
import au.edu.unsw.infs3634.gamifiedlearning.model.VideoListModel;

public class VideoListActivity extends AppCompatActivity {

    private static final String[] NAMES = new String[]{"消防安全(一)", "消防安全(二)", "消防安全(三)", "消防安全(四)", "消防安全(五)"};

    private static final int[] ICONS = new int[]{R.mipmap.ic_africa, R.mipmap.ic_asia, R.mipmap.ic_europe, R.mipmap.ic_america, R.mipmap.ic_oceania};

    private static final String[] DATES = new String[]{"2022-10-02", "2022-12-01", "2023-01-01", "2023-01-06", "2022-01-08"};

    private static final String[] URLS = new String[]{"https://vd3.bdstatic.com/mda-mm9cgpm1btwxhvbs/sc/cae_h264_nowatermark/1639127085506674619/mda-mm9cgpm1btwxhvbs.mp4?v_from_s=hkapp-haokan-hbe&auth_key=1675755081-0-0-502d6ec89d8427ec0680ff5b5b610ecc&bcevod_channel=searchbox_feed&cd=0&pd=1&pt=3&logid=0081275851&vid=10167691584334805284&abtest=106847_2-107354_2&klogid=0081275851", "https://vd2.bdstatic.com/mda-mmmc9j778ruvzsgh/sc/cae_h264_nowatermark/1640164717345903261/mda-mmmc9j778ruvzsgh.mp4?v_from_s=hkapp-haokan-hbe&auth_key=1675755147-0-0-7db0acb063f84527131544b7ab6e70fa&bcevod_channel=searchbox_feed&cd=0&pd=1&pt=3&logid=0147288184&vid=15243723544448234846&abtest=106847_2-107354_2&klogid=0147288184", "https://vd3.bdstatic.com/mda-nmd4584d8bkwfm6h/720p/h264/1670986629944304865/mda-nmd4584d8bkwfm6h.mp4?v_from_s=hkapp-haokan-hbe&auth_key=1675755205-0-0-070fa3f48810c50c709c2b217722f1d5&bcevod_channel=searchbox_feed&cd=0&pd=1&pt=3&logid=0205317511&vid=11990721039116275194&abtest=106847_2-107354_2&klogid=0205317511", "https://vd2.bdstatic.com/mda-kmhnnjeajaxv5rm0/v1-cae/sc/mda-kmhnnjeajaxv5rm0.mp4?v_from_s=hkapp-haokan-hbe&auth_key=1675755254-0-0-77e809a7b3c43ef8dd9620bf71e34672&bcevod_channel=searchbox_feed&cd=0&pd=1&pt=3&logid=0254850336&vid=16153086648451305029&abtest=106847_2-107354_2&klogid=0254850336", "https://vd2.bdstatic.com/mda-nh44u1y56ijiwevn/cae_h264/1659678042179636007/mda-nh44u1y56ijiwevn.mp4?v_from_s=hkapp-haokan-hbe&auth_key=1675755300-0-0-3c35db44d54a73a9c61f25f4c0d92188&bcevod_channel=searchbox_feed&cd=0&pd=1&pt=3&logid=0300893901&vid=3738877011591362803&abtest=106847_2-107354_2&klogid=0300893901"};


    private RecyclerView rvList;

    private VideoListAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_list2);
        initView();
    }

    private void initView() {
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        setTitle("培训资料");
        rvList = (RecyclerView) findViewById(R.id.rv_list);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(RecyclerView.VERTICAL);
        rvList.setLayoutManager(linearLayoutManager);

        adapter = new VideoListAdapter(this, getVideoList(), new VideoListAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(VideoListModel model) {

            }
        });
        rvList.setAdapter(adapter);
    }

    private List<VideoListModel> getVideoList() {
        List<VideoListModel> list = new ArrayList<>();
        for (int i = 0; i < NAMES.length; i++) {
            VideoListModel model = new VideoListModel(NAMES[i], ICONS[i], DATES[i], URLS[i]);
            list.add(model);
        }
        return list;
    }

    //Back button
    @Override
    public boolean onSupportNavigateUp() {
        finish();
        return true;
    }
}